package com.aaa.java13.generic;

import com.aaa.java13.MyPerson;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/16 17:05
 * @description：
 * @modified By：
 * @version:
 */
public class Student {
    int id;
    //通配符上限，支持Shape的子类和自己
    public static void  drawAll(List<? extends Shape> shapeList){
       /* for (Object o : shapeList) {
            o.
        }*/
        /*for (Circle circle : shapeList) {
            circle.draw();
        }*/
        for (Shape shape : shapeList) {
            shape.draw();
        }
    }

    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description:  泛型下限
     * @create time: 2022/7/16 17:14
     * @param a
     * @param b
     * @return void
     */
    public static <T> void fromSonListToFatherList(List<T> a, List<? super T> b) {

        for (T t : a) {
            //b装a，所有b的范围大于等于a
            b.add(t);
        }
    }


    public static void main(String[] args) {
      /*  List shapeList= new ArrayList();
        shapeList.add(new Circle());*/
  /*      List<Circle> circleList= new ArrayList<>();
        circleList.add(new Circle());*/
        List<Shape> circleList= new ArrayList<>();
        circleList.add(new Circle());
        Student.drawAll(circleList);

      /*  List<Student> students= new ArrayList<>();
        students.add(new Student());
        for (Student student : students) {
            System.out.println(student.id);
        }
        List list =new ArrayList();
        list=students;
        for (Object o : list) {
            System.out.println(o);
        }*/
    }
}
